//
//  ZRPhotoKitManager.m
//  TestFile
//
//  Created by 黄涛 on 2018/7/31.
//  Copyright © 2018年 アポロジャパン. All rights reserved.
//

#import "ZRPhotoKitManager.h"
#import <Photos/Photos.h>
@implementation ZRPhotoKitManager

/** 获取相册列表:(系统相册 + 个人相册) */
- (void)getAllAlbums{
    
    NSMutableArray * arr = [NSMutableArray array];
    PHFetchOptions * options = [[PHFetchOptions alloc] init];
    //排序方式 : 名称
    options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"localizedTitle" ascending:YES]];
    
    PHFetchResult * smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil];
    
    PHFetchResult * userAlbums = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil];

    
    [smartAlbums enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        PHAssetCollection * _Nonnull ac = obj;
        
        //过滤掉视频 和 最近删除
        if (![ac.localizedTitle isEqualToString:@"Recently Deleted"] || ![ac.localizedTitle isEqualToString:@"Hidden"]) {
            
         //   NSArray * assets = [self getAssetsWithAssetCollection:ac ascending:YES];
            
//            if (assets.count > 0) [arr addObject:ac];
        }
        
    }];
    
    
    [userAlbums enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
       
        
        [arr addObject:obj];
        
    }];
    
}



/** 相册名称转换:英文转中文 */



/** 获取相册中所有图片资源 */






@end
